package com.cjq.auth.handle;

import com.cjq.auth.exception.ServiceException;
import com.cjq.common.result.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局统一异常
 */
@RestControllerAdvice
@Log4j2
public class GlobalServiceException {

    @ExceptionHandler(ServiceException.class)
    public Result serviceException(ServiceException e) {
        log.error("业务异常：{}", e.getMessage());
        return Result.success(e.getMessage());
    }
}
